package com.pt25.service.sys.repository.mysql.persistence.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pt25.base.util.PageUtil;
import com.pt25.service.sys.domain.config.ddo.ConfigLog;
import com.pt25.service.sys.repository.mysql.mapper.ConfigLogMapper;
import com.pt25.service.sys.repository.mysql.persistence.ConfigLogRepo;
import com.pt25.service.sys.repository.mysql.po.ConfigLogPo;
import org.springframework.stereotype.Service;

@Service
public class ConfigLogRepoImpl extends ServiceImpl<ConfigLogMapper, ConfigLogPo> implements ConfigLogRepo {
    @Override
    public PageUtil.PageVo pageConfigLog(ConfigLog configLog) {
        IPage<ConfigLogPo> page = new Page<>(configLog.getPageNum(), configLog.getPageSize());
        QueryWrapper<ConfigLogPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ConfigLogPo::getDelFlag, 0);
        if (null != configLog.getConfigValueId()) {
            queryWrapper.lambda().eq(ConfigLogPo::getConfigValueId, configLog.getConfigValueId());
        }
        page(page, queryWrapper);
        return PageUtil.PageVo.builder()
                .total(page.getTotal())
                .pageNum(page.getCurrent())
                .pageSize(page.getSize())
                .list(page.getRecords())
                .build();
    }
}
